@extends('../manage.layout')
@section('content')
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            案例管理
            <small>分类添加</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Level</a></li>
            <li class="active">Here</li>
        </ol>
    </section>
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <!-- general form elements -->
                <div class="box-body table-responsive no-padding">
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">分类添加</h3>
                        </div>
                        <!-- /.box-header -->
                        <!-- form start -->
                        <form method="post" action="{{ url('manage/casecate') }}" enctype=”multipart/form-data”>
                            {{--{{ csrf_field() }}--}}
                            <input type="hidden" name="_token" value="{{ csrf_token() }}">
                            <div class="box-body">
                                <div class="form-group">
                                    <label for="">父级分类</label>
                                    <select class="form-control" name="parent">
                                        <option value="">请选择</option>
                                        @foreach($cases as $case)
                                            @if($case->parent == 0)
                                                <option value="{{ $case->id }}">{{ $case->name }}</option>
                                            @endif
                                        @endforeach
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="name">分类名称</label>
                                    <input type="input" class="form-control" id="name" name="name" placeholder="新增分类名">
                                </div>

                            </div>
                            <!-- /.box-body -->

                            <div class="box-footer">
                                <button type="submit" class="btn btn-primary">确定</button>&nbsp;&nbsp;<span class="btn btn-primary" onclick="window.location.href='/manage/category'">返回</span>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!-- /.content -->
@endsection
@section('script')
@endsection
<script src="/plugin/jquery/jquery-2.2.1.min.js"></script>
<script src="/plugin/layer-2.4/layer.js"></script>
<script type="text/javascript">
    $(function () {
        $("form").submit(function(event) {
            event.preventDefault();
            var url = $(this).attr('action');
            ajaxToken({
                url: url,
                type: "POST",
                data: $("form").serialize(),
                dataType: "json",
                success: function(data) {
                    console.log(data);
                    layer.msg(data.msg);
                }
            });
        });
    });
</script>
